<!--#include file="../nav/admin_top.php" -->  
<script type="text/javascript">
var url_save = '<?=url::build('admin_point','add',array('reqtype'=>'json'))?>'; 
var url_return = '<?=url::build('admin_point','index')?>';   

$().ready(function(){  
	showLoading();   

});
 
/* 保存 */
function fnSave(){ 
	var form = serializeObj("#myform");
   
	/* 一些验证 */
	if( form.user_id == '' ){
		alert('请选择会员');
		fnGetUser();
		return false;
	}
	if($.trim(form.point) == '' || !fnRegExp('reg_int1',form.point)){
		alert('请填写正确的积分');
		$('#point').focus();
		return false;
	}
	
	$('button').attr('disabled','disabled');
	$.post(
		url_save,
		{
			form:JSON.encode(form)
		},
		function(e){
			var ok = errorHandler(e);
			if(ok && ok.success=='1'){
				jumpTo(url_return);
			}
			$('button').attr('disabled','');
		}
	);
	return false;
}
function fnDelUser(){
	$('#user_id').val('');
	$('#slt_user_span').html(' ');
	$('#slt_user_a').html('选择会员');
	$('#del_user_span').hide();
}
/* 选择会员 */
function fnGetUser(){
	GfnSelectUser('onFnGetUser','选择会员');
}
function onFnGetUser(e){
  $('#user_id').val('');
	$('#slt_user_span').html(' ');
	var html = [];
	var ids  = [];
	for(var i=0; i<e.user_ids.length ; i++){
		html.push('('+e.user_ids[i].username+')'+e.user_ids[i].name);
		ids.push(e.user_ids[i].id);
	}
  $('#user_id').val(ids.join(','));
	$('#slt_user_span').html(html.join(' , '));
	$('#slt_user_a').html('更换用户');
	$('#del_user_span').show(); 
} 

</script>
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">积分事务 - 添加</span>
	</div>
</div>
<form id="myform" action="" method="post" onsubmit="return false;">
<div class="blockdiv">
	<div class="titlediv">添加积分事务</div>
	<table class="mytable" >
		<tr>
			<td class="mylabel">会员：</td>
			<td class="myinfo" >
				<span id="slt_user_span"> </span>
				<span id="del_user_span" style="display:none"><a href="javascript:void(0)"  onclick="fnDelUser()">清除</a> 或 </span>
				<a href="javascript:void(0)" id="slt_user_a"  onclick="fnGetUser()" title="请点击选择">选择会员</a>
				<input type="hidden" id="user_id" name="user_id" value="" />
			</td>
		</tr>
		<tr>
			<td class="mylabel">类别：</td>
			<td class="myinfo" >
				<select class="textBox" id="pointtype_id" name="pointtype_id" >
					<?PHP
					foreach($pointtype as $v){ 
						echo '<option value="'.$v['id'].'">'.$v['name'].' ( '.$v['actions'].' )</option>'; 
					}
					?>
				</select> 
				<span style="color:#999999">"+"代表增加积分、 "-" 代表扣除积分</span>
			</td>
		</tr>
		<tr>
			<td class="mylabel">积分：</td>
			<td class="myinfo" >
				<input type="text" class="textBox" name="point" id="point" style="text-align:right" maxlength="15" /> 分
			</td>
		</tr>
		<tr>
			<td class="mylabel">备注：</td>
			<td class="myinfo" >
				<textarea name="remark" class="textBox" style="width:80%;height:90px"></textarea>
			</td>
		</tr>
	</table>
</div>
 
</form>	
<div  class="button_div">
	<button class="btn_save" onclick="fnSave()">保 存</button>
	<span class="gray">或</span> 
	<button class=" " onclick="jumpTo(url_return);return false;">返 回</button>
</div>  
<!--#include file="../nav/admin_bottom.php" -->